for (var e = new Date(), t = [], s = [], a = [], i = 1970; i <= e.getFullYear(); i++) t.push(i);

for (var n = 1; n <= 12; n++) n < 10 ? s.push("0" + n) : s.push(n);

for (var l = 1; l <= 31; l++) l < 10 ? a.push("0" + l) : a.push(l);

Component({
    properties: {
        question: {
            type: Object,
            value: {}
        },
        answer: {
            type: Object,
            value: {}
        },
        site: {
            type: Number,
            value: 0
        }
    },
    data: {
        years: t,
        months: s,
        days: a,
        selected: [ 5, 5, 5 ]
    },
    ready: function() {
        var e = this.data.answer.answer;
        if (e) {
            console.log("zhix", e);
            var i = e.split("-");
            console.log(i);
            var n = [];
            i[0] = parseInt(i[0]), parseInt(i[1]) >= 10 && (i[1] = parseInt(i[1])), parseInt(i[2]) >= 10 && (i[2] = parseInt(i[2])), 
            console.log(i), n[0] = t.indexOf(i[0]) > -1 ? t.indexOf(i[0]) : 0, n[1] = s.indexOf(i[1]) > -1 ? s.indexOf(i[1]) : 0, 
            n[2] = a.indexOf(i[2]) > -1 ? a.indexOf(i[2]) : 0, console.log(n), this.setData({
                selected: n
            });
        } else this.triggerEvent("quesCallback", {
            question: this.data.question,
            site: this.data.site,
            answer: t[this.data.selected[0]] + "-" + s[this.data.selected[1]] + "-" + a[this.data.selected[2]]
        });
    },
    methods: {
        change: function(e) {
            var i = e.detail.value;
            console.log(i), console.log(s[i[1]]);
            var n = parseInt(s[i[1]]);
            if (console.log(n), i[0] != this.data.selected[0] || i[1] != this.data.selected[1]) {
                for (var l = function(e, t) {
                    return [ 31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ][t] || (function(e) {
                        return e % 400 == 0 || e % 100 != 0 && e % 4 == 0;
                    }(e) ? 29 : 28);
                }(t[i[0]], n - 1), o = [], r = 1; r <= l; r++) r < 10 ? o.push("0" + r) : o.push(r);
                this.setData({
                    days: o
                });
            }
            this.setData({
                selected: i
            }), this.triggerEvent("quesCallback", {
                question: this.data.question,
                site: this.data.site,
                answer: t[this.data.selected[0]] + "-" + s[this.data.selected[1]] + "-" + a[this.data.selected[2]]
            });
        }
    }
});